<?php
if(isset($_GET['table']) && isset($_POST['hid_order'])){	
require_once 'config.php';	

	$sp_order 	= split(' ',$_POST['hid_order']);
		
	//$page 		= $_POST['hid_page'];
	//$display_rec 	= $_POST['hid_display_rec'];
	//$ordering		= ($page - 1) * $display_rec;
	
	$len = sizeof($sp_order);
	
	for($i=0; $i<$len; $i++){
		$ordering++;
		$sql = "UPDATE $_GET[table] 
				SET ordering= $ordering 
				WHERE id=$sp_order[$i]";
		mysql_query($sql);
	}
	
	$sql = "ALTER TABLE $_GET[table] 
			ORDER BY ordering";

	mysql_query($sql);
	
	if($i == $len)
		alertmsg("Completed");
	else
		alertmsg("Incompleted");
}
?>